import { reqAttrInfoList, reqCategory1, reqCategory2,reqCategory3, reqSaveAttr } from "@/api/product/attr";
import { defineStore } from "pinia";
const useCategory=defineStore('category',{
    state:()=>{
        return{
            c1Arr:[],
            c2Arr:[],
            c3Arr:[],
            c1Id:'',
            c2Id:'',
            c3Id:'',
            attrInfoList:[]

        }
    },
    actions:{
       async reqc1Arr(){
            let res:any=await reqCategory1()
            this.c1Arr=res
            
        },
        async reqc2Arr(){
              this.c2Arr=[]
              this.c2Id=''
              this.c3Id=''
              this.c3Arr=[]
            let  res:any=await reqCategory2(this.c1Id)
            this.c2Arr=res
            
        
            
        },
        async reqc3Arr(){
            this.c3Arr=[]
            this.c3Id=''
            let res:any=await  reqCategory3(this.c2Id)
            this.c3Arr=res
            

        },
        async reqAttrList(){
            let c1Id=this.c1Id,c2Id=this.c2Id,c3Id=this.c3Id
            let res:any=await reqAttrInfoList(c1Id,c2Id,c3Id)
            console.log(res);
            this.attrInfoList=res
            

        },
        async reqSaveAtrrInfo(data:any){
            let res:any=await reqSaveAttr(data)
            

        }

    }
})
export  default  useCategory